<template>
  <div class="collect">
    <van-nav-bar title="收藏列表" left-arrow fixed @click-left="onClickLeft" />
    <van-list
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <house-item
        v-for="item in collectList"
        :key="item.id"
        :item="item"
      ></house-item>
    </van-list>
  </div>
</template>

<script>
import HouseItem from '@/components/HuoseItem.vue'
import { getCollect } from '@/api/user'
export default {
  name: 'collect-page',
  components: { HouseItem },
  data () {
    return {
      collectList: [],
      finished: false
    }
  },
  methods: {
    onClickLeft () {
      this.$router.back()
    },
    async onLoad () {
      const res = await getCollect()
      console.log(res)
      this.finished = true
      const list = res.body
      list.forEach((item) => {
        item.houseImg = 'http://liufusong.top:8080' + item.houseImg
      })
      console.log(list)
      this.collectList = list
    }
  }
}
</script>

<style lang="less" scoped>
.collect {
  margin-bottom: 50px;
  margin-top: 50px;
}
</style>
